package leesoft.configuration.databeans;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.dom4j.Element;

import leesoft.configuration.interfaces.IXmlToBean;

public class Plugin implements IXmlToBean {
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public void setClassName(String className) {
		this.className = className;
	}
	public void setParametersMap(Map<String, String> parametersMap) {
		this.parametersMap = parametersMap;
	}
	public String getClassName() {
		return className;
	}
	public Map<String, String> getParametersMap() {
		return parametersMap;
	}
	String className;
	Map<String,String> parametersMap=new HashMap<String,String>();
	String id;
	@Override
	public void convertXml(Element element) {
		// TODO Auto-generated method stub
		className=element.attributeValue("class");
		id=element.attributeValue("id");
		List<Element> parameters=(List<Element>) element.elements("parameter");
		if(parameters==null)
			return;
		for(Element p:parameters){
			String value=p.attributeValue("value");
			if(value==null){
				value=p.getTextTrim();
			}
			parametersMap.put(p.attributeValue("key"),value);
		}
	}
}
